<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title></title>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <script th:src="@{/static/main.js}"></script>

    <style>
        body {
            background-image: url("/static/56071023_p0.jpg");
            background-size: cover;
        }
        .cover {
            display: inline-block;
            width: 30px;
            height: 30px;
            position: absolute;
            right: 13px;
            top: 118px;
            z-index: 100;
            cursor: pointer;
        }
        .eye2 {
            top: 193px;
        }
    </style>
</head>
<body>
<!--颜醉-->
<!--用户注册页面-->

<div class="text-center" style="margin-top: 100px">
    <h1>
        <a th:href="@{/}" style="color: #642d2e;text-decoration: none">蜗牛餐饮</a>
    </h1>
</div>
<div class="container-fluid" id="app" style="margin-top: 30px;margin-bottom: 100px">

    <div class="container">

        <div class="row">
            <a href="/userlogin.html" style="color: rebeccapurple;font-size: 20px;text-decoration: none">已有账号?立即去登录</a>
            <div class="col-md-4 col-md-offset-4" style="border: 1px solid #cccccc ;border-radius: 5px;margin-top: 40px;backdrop-filter: blur(50px);box-shadow: 0 0 40px 10px rgba(0, 0, 0, .3)">
                <form action="/user/reg" method="post">
                    <p style="color: red" th:text="${errorInfo}">errorInfo</p>
                    <div class="form-group">
                        <label for="account">用户名</label>
                        <input type="text" name="username" class="form-control" id="account" placeholder="请输入用户名">
                    </div>
                    <div class="form-group">
                        <label for="inputPassWord">密码</label>
                        <input :type="flagType" name="password" class="form-control fc-clear"
                               id="inputPassWord" placeholder="请输入密码">
                        <span class="cover eye input-icon input-icon-md" @click.prevent="getFlag()"
                              style="display: inline">
                                    <span :class="isOpen" style="color: rgba(141,134,139,0.71);"></span>
                                </span>
                    </div>
                    <div class="form-group">
                        <label for="repass">确认密码</label>
                        <input :type="flagType2" name="repass" class="form-control fc-clear"
                               id="repass" placeholder="请输入确认密码">
                        <span class="cover eye2 input-icon input-icon-md" @click.prevent="getFlag2()"
                              style="display: inline">
                                    <span :class="isOpen2" style="color: rgba(141,134,139,0.71);"></span>
                                </span>
                    </div>
                    <div class="form-group">
                        <label for="tel">电话</label>
                        <input type="password" name="tel" class="form-control" id="tel" placeholder="请输入电话">
                    </div>

                    <div class="form-group">
                        <label for="email">邮箱</label>
                        <input type="email" name="email" v-model="emailAddress" class="form-control" id="email" style="margin-bottom: 10px" placeholder="请输入邮箱">
                        <button class="btn btn-primary" @click.prevent="getEmailCode">获取验证码</button>
                    </div>
                    <div class="form-group">
                        <label for="emailCode">请输入验证码</label>
                        <input type="text" name="emailCode" class="form-control" id="emailCode" placeholder="请输入邮箱验证码">
                    </div>

                    <button type="submit" class="btn btn-success" style="margin-bottom: 10px">注册</button>
                </form>
            </div>
        </div>

    </div>

</div>

<script>

    console.log(".........register...........")

    let register = new Vue({
        el: "#app"
        ,
        data: {
            emailAddress:"",
            flag: false,
            flagType: 'password',
            isOpen: 'glyphicon glyphicon-eye-open',

            flag2: false,
            flagType2: 'password',
            isOpen2: 'glyphicon glyphicon-eye-open'
        }
        ,
        methods: {
            getEmailCode(){
                console.log(this.emailAddress)
                $.post("/user/getEmailCode",{"email":this.emailAddress},function (data) {
                    if (data=="ok"){
                        alert("验证码发送成功")
                    }else {
                        alert(data)
                    }
                })
            }
            ,
            //小眼睛切换状态
            getFlag() {
                this.flag = !this.flag;
                this.flagType = this.flag ? 'text' : 'password';//text为显示密码；password为隐藏密码

                this.isOpen = this.flag ? 'glyphicon glyphicon-eye-close' : 'glyphicon glyphicon-eye-open' ;//close为闭眼；open为睁眼
            }
            ,
            getFlag2() {
                this.flag2 = !this.flag2;
                this.flagType2 = this.flag2 ? 'text' : 'password';//text为显示密码；password为隐藏密码

                this.isOpen2 = this.flag2 ? 'glyphicon glyphicon-eye-close' : 'glyphicon glyphicon-eye-open' ;//close为闭眼；open为睁眼
            }

        }
        ,
        created(){

        }

    });


</script>


</body>
</html>